<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <script src="https://cdn.jsdelivr.net/npm/vue"></script>
    <title>插槽编辑作用域</title>
</head>
<body>
<div id="app">
    <navigation-link url="/profile">
      {{user.name}}
      <!-- 访问不到url，因为插槽部分只能访问到当前大环境下的vue实例，而访问不到navigation-link的作用域 -->
      <!-- {{url}} --> 
    </navigation-link>
</div>

<script>
     Vue.component('navigation-link', {
        props: ['url'],
        template: `
            <a
            v-bind:href="url"
            class="nav-link"
            >
            <slot></slot>
            </a>
        `
    })
    new Vue({
        el: '#app',
        data: function (){
            return {
                user: {
                  name: 'lican'
                }
            }
        }
    })


</script>
</body>
</html>